package com.gcl.rabbitmq;

import com.gcl.rabbitmq.utils.RabbitMQUtils;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class Consumer02 {


    public static final String EXCHANGE_NAME = "topic";

    public static void main(String[] args) throws IOException, TimeoutException {

        Channel channel = RabbitMQUtils.getChannel();

        channel.exchangeDeclare(EXCHANGE_NAME, BuiltinExchangeType.TOPIC);

        channel.queueDeclare("Q2", false, false, false, null);

        channel.queueBind("Q2", EXCHANGE_NAME, "lazy.#");

        channel.queueBind("Q2", EXCHANGE_NAME, "*.*.rabbit");


        DeliverCallback deliverCallback = (a ,b) -> {
            System.out.println("Q2打印 "+ new String(b.getBody()));
        };

        CancelCallback cancelCallback = (a) ->{};

        channel.basicConsume("Q2", true, deliverCallback, cancelCallback);

    }


}
